home *** CD-ROM | disk | FTP | other *** search
/ AGA Toolkit '97 / The AGA Toolkit '97.iso / programming / gcc / gcc2.7.0 / gcc270cp.lha / gnu / lib / g++-include / std / fcomplex.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-28  |  3.9 KB  |  79 lines

  1. // The -*- C++ -*- float_complex class.
  2. // Copyright (C) 1994 Free Software Foundation
  3.  
  4. // This file is part of the GNU ANSI C++ Library.  This library is free
  5. // software; you can redistribute it and/or modify it under the
  6. // terms of the GNU General Public License as published by the
  7. // Free Software Foundation; either version 2, or (at your option)
  8. // any later version.
  9.  
  10. // This library is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14.  
  15. // You should have received a copy of the GNU General Public License
  16. // along with this library; see the file COPYING.  If not, write to the Free
  17. // Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18.  
  19. // As a special exception, if you link this library with files
  20. // compiled with a GNU compiler to produce an executable, this does not cause
  21. // the resulting executable to be covered by the GNU General Public License.
  22. // This exception does not however invalidate any other reasons why
  23. // the executable file might be covered by the GNU General Public License.
  24.  
  25. // Written by Jason Merrill based upon the specification in the 27 May 1994
  26. // C++ working paper, ANSI document X3J16/94-0098.
  27.  
  28. #ifdef __GNUG__
  29. #pragma interface "fcomplex"
  30. #endif
  31.  
  32. class complex<float>
  33. {
  34. public:
  35.   complex (float r = 0, float i = 0): re (r), im (i) { }
  36.   explicit complex (const complex<double>& r);
  37.   explicit complex (const complex<long double>& r);
  38.  
  39.   complex& operator+= (const complex&);
  40.   complex& operator-= (const complex&);
  41.   complex& operator*= (const complex&);
  42.   complex& operator/= (const complex&);
  43.  
  44.   float real () const { return re; }
  45.   float imag () const { return im; }
  46. private:
  47.   float re, im;
  48.  
  49.   // These functions are specified as friends for purposes of name injection;
  50.   // they do not actually reference private members.
  51.   friend float real (const complex& x) { return x.real (); }
  52.   friend float imag (const complex& x) { return x.imag (); }
  53.   friend complex operator + (const complex&, const complex&) __attribute__ ((const));
  54.   friend complex operator + (const complex&, float) __attribute__ ((const));
  55.   friend complex operator + (float, const complex&) __attribute__ ((const));
  56.   friend complex operator - (const complex&, const complex&) __attribute__ ((const));
  57.   friend complex operator - (const complex&, float) __attribute__ ((const));
  58.   friend complex operator - (float, const complex&) __attribute__ ((const));
  59.   friend complex operator * (const complex&, const complex&) __attribute__ ((const));
  60.   friend complex operator * (const complex&, float) __attribute__ ((const));
  61.   friend complex operator * (float, const complex&) __attribute__ ((const));
  62.   friend complex operator / (const complex&, const complex&) __attribute__ ((const));
  63.   friend complex operator / (const complex&, float) __attribute__ ((const));
  64.   friend complex operator / (float, const complex&) __attribute__ ((const));
  65.   friend bool operator == (const complex&, const complex&) __attribute__ ((const));
  66.   friend bool operator == (const complex&, float) __attribute__ ((const));
  67.   friend bool operator == (float, const complex&) __attribute__ ((const));
  68.   friend bool operator != (const complex&, const complex&) __attribute__ ((const));
  69.   friend bool operator != (const complex&, float) __attribute__ ((const));
  70.   friend bool operator != (float, const complex&) __attribute__ ((const));
  71.   friend complex polar (float, float) __attribute__ ((const));
  72.   friend complex pow (const complex&, const complex&) __attribute__ ((const));
  73.   friend complex pow (const complex&, float) __attribute__ ((const));
  74.   friend complex pow (const complex&, int) __attribute__ ((const));
  75.   friend complex pow (float, const complex&) __attribute__ ((const));
  76.   friend istream& operator>> (istream&, complex&);
  77.   friend ostream& operator<< (ostream&, const complex&);
  78. };
  79.